Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle reparenting of controls #3004

Merged
merged 3 commits into from
Sep 19, 2019

Conversation

grokys
Copy link
Member

@grokys grokys commented Sep 17, 2019

What does the pull request do?

#2982 describes how a crash can occur in the deferred renderer when a control is reparented. Fix that crash by renaming VisualNode.SortChildren -> UpdateChildren and make it remove nodes for controls that are no longer children.

Checklist

  • Added unit tests (if possible)?

Fixed issues

Fixes #2982

Crash in renderer when reparenting a control.
Renamed `VisualNode.SortChildren` -> `UpdateChildren` and make it remove nodes for controls that are no longer children.
@grokys grokys requested review from MarchingCube and a team September 17, 2019 13:49
@@ -193,9 +193,12 @@ public void SortChildren(Scene scene)
keys.Add(((long)zIndex << 32) + i);
}

var toRemove = _children.ToList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to use a pooled list instance to reduce allocations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I figured that there's already so many allocations in the renderer that one more won't make much difference, and we can address when we address the rest of them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocating huge arrays (which List internally does) can have a huge impact since they can end up in LOH.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH it would require to have around 20k children to end up on LOH. Although we already have renderer objects in LOH (dirty visuals). We also reallocate all nodes, children, etc. per render. Maybe we should create new task for tracking potential renderer refactor.

Copy link
Member

@danwalmsley danwalmsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, doesnt seem to break anything major :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reparented controls are positioned incorrectly
4 participants